<?php

namespace App\Services\Menu;

use App\Models\Category;
use App\Models\Menu;
use Log;

/**
 * 菜单服务
 * @package App\Services\Menu
 */
class MenuService
{
    public function generate()
    {
        $categories = Category::all();

    }


    public static function getChildren($arr, $pid = 0)
    {
        $tree = [];
        foreach ($arr as $key => $v) {
            if ($v['pid'] == $pid) {
                $v['children'] = self::getChildren($arr, $v['id']);
                $tree[] = $v;
            }
        }
        return $tree;
    }

}
